package com.teamcenter.rac.massupdate.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertySource;

import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.massupdate.Activator;
import com.teamcenter.rac.massupdate.databinding.AbstractModelObservable;
@SuppressWarnings({"rawtypes","unchecked"})
public abstract class AbstractObservablePropertySource
  implements IPropertySource
{
  public PropertyChangeSupport m_propertyChangeSupport;
  protected Map<String, Object> m_propertyValueMap;
  private TCSession m_tcSession;
  
  protected AbstractObservablePropertySource(int paramInt)
  {
    this.m_propertyValueMap = new HashMap(paramInt);
    this.m_propertyChangeSupport = new PropertyChangeSupport(this);
  }
  
  public void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    this.m_propertyChangeSupport.addPropertyChangeListener(paramPropertyChangeListener);
  }
  
  public void addPropertyChangeListener(String paramString, PropertyChangeListener paramPropertyChangeListener)
  {
    this.m_propertyChangeSupport.addPropertyChangeListener(paramString, paramPropertyChangeListener);
  }
  
  public Object getEditableValue()
  {
    return null;
  }
  
  public Object getPropertyValue(Object paramObject)
  {
    if (paramObject != null) {
      return this.m_propertyValueMap.get(paramObject);
    }
    return null;
  }
  
  public boolean isPropertySet(Object paramObject)
  {
    if (paramObject != null) {
      return this.m_propertyValueMap.containsKey(paramObject);
    }
    return false;
  }
  
  public void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    this.m_propertyChangeSupport.removePropertyChangeListener(paramPropertyChangeListener);
  }
  
  public void removePropertyChangeListener(String paramString, PropertyChangeListener paramPropertyChangeListener)
  {
    this.m_propertyChangeSupport.removePropertyChangeListener(paramString, paramPropertyChangeListener);
  }
  
  public void resetPropertyValue(Object paramObject)
  {
    this.m_propertyValueMap.remove(paramObject);
  }
  
  public void setPropertyValue(Object paramObject1, Object paramObject2)
  {
    if (paramObject1 != null) {
      updateAndAnnounceProperty((String)paramObject1, paramObject2);
    }
  }
  
  protected void firePropertyChange(String paramString, Object paramObject1, Object paramObject2)
  {
    this.m_propertyChangeSupport.firePropertyChange(paramString, paramObject1, paramObject2);
  }
  
  protected boolean getPropertyValueAsBoolean(String paramString)
  {
    Boolean localBoolean = (Boolean)getPropertyValue(paramString);
    if (localBoolean == null) {
      localBoolean = Boolean.FALSE;
    }
    return localBoolean.booleanValue();
  }
  
  protected TCSession getTCSession()
  {
    try
    {
      if (this.m_tcSession == null) {
        this.m_tcSession = ((TCSession)Activator.getDefault().getSessionService().getSession(TCSession.class.getName()));
      }
    }
    catch (Exception localException)
    {
      Logger.getLogger(AbstractModelObservable.class).error(localException.getLocalizedMessage(), localException);
    }
    return this.m_tcSession;
  }
  
  protected void updateAndAnnounceImageProperty(String paramString, Image paramImage)
  {
    Image localImage = (Image)this.m_propertyValueMap.get(paramString);
    if (localImage != paramImage)
    {
      if ((localImage != null) && (!localImage.isDisposed())) {
        localImage.dispose();
      }
      this.m_propertyValueMap.put(paramString, paramImage);
      firePropertyChange(paramString, localImage, paramImage);
    }
  }
  
  protected void updateAndAnnounceProperty(String paramString, Object paramObject)
  {
    Object localObject = this.m_propertyValueMap.get(paramString);
    this.m_propertyValueMap.put(paramString, paramObject);
    firePropertyChange(paramString, localObject, paramObject);
  }
}


/* Location:              D:\下载\Fw_ 金卡反编译需求\com.teamcenter.rac.massupdate_11000.2.0.jar!\com\teamcenter\rac\massupdate\model\AbstractObservablePropertySource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */